package com.wenlin.image.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/***
 *  Created with IntelliJ IDEA.
 *  User:  wenlin
 *  Date:  2017/12/05
 *  Time:  14:03
 *  Description:在线api文档swagger配置
 **/
@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Value("${spring.application.name}")
    private String applicationName;

    @Bean
    public Docket api1() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo()).groupName(applicationName)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.ant("/image/**"))
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("")
                .description("")
                .termsOfServiceUrl("")
                .contact(contact())
                .version("1.0")
                .build();
    }


    private Contact contact() {
        return new Contact("WenLin", "", "1041905567@qq.com");
    }

}
